package com.yizisu.playerlibrary.view.video_view.helper

import android.view.View
import androidx.lifecycle.LiveData
import androidx.lifecycle.MutableLiveData
import com.yizisu.playerlibrary.IYzsPlayer


/**
 * 信息共享和交互配置类
 */
class IPlayerConfigImpl : IPlayerConfig {
    private val _playerData by lazy {
        MutableLiveData<Pair<IYzsPlayer<IYzsPlayer.Model>?, IYzsPlayer<IYzsPlayer.Model>?>>()
    }
    override val playerData: LiveData<Pair<IYzsPlayer<IYzsPlayer.Model>?, IYzsPlayer<IYzsPlayer.Model>?>>
        get() = _playerData

    override fun updatePlayer(player: IYzsPlayer<IYzsPlayer.Model>?) {
        _playerData.updateValue(Pair(_playerData.value?.second, player))
    }

    private val _seekBarEventData by lazy {
        MutableLiveData<SeekbarEvent>()
    }
    override val seekBarEventData: LiveData<SeekbarEvent>
        get() = _seekBarEventData

    override fun updateSeekBarEvent(value: SeekbarEvent?) {
        _seekBarEventData.updateValue(value)
    }

    private val _showOrHideControllerData by lazy {
        MutableLiveData<Float>()
    }
    override val showOrHideControllerData: LiveData<Float>
        get() = _showOrHideControllerData

    override fun updateShowOrHideController(value: Float?) {
        _showOrHideControllerData.updateValue(value)
    }

    private val _maxSwipeDurationData by lazy {
        MutableLiveData<Pair<Long, Long>>()
    }
    override val maxSwipeDurationData: LiveData<Pair<Long, Long>>
        get() = _maxSwipeDurationData

    override fun updateMaxSwipeDuration(value: Pair<Long, Long>?) {
        _maxSwipeDurationData.updateValue(value)
    }

    private val _screenNotLockData by lazy {
        MutableLiveData<Boolean>()
    }

    override val screenNotLockData: LiveData<Boolean>
        get() = _screenNotLockData

    override fun updateScreenNotLock(value: Boolean?) {
        _screenNotLockData.updateValue(value)
    }

    private val _playerControllerBarHelperData by lazy {
        MutableLiveData<PlayerControllerBarHelper>()
    }

    override val playerControllerBarHelperData: LiveData<PlayerControllerBarHelper>
        get() = _playerControllerBarHelperData

    override fun updatePlayerControllerBarHelper(value: PlayerControllerBarHelper?) {
        _playerControllerBarHelperData.updateValue(value)
    }

    private val _longPressedSpeedData by lazy {
        MutableLiveData<Float>()
    }

    override val longPressedSpeedData: LiveData<Float>
        get() = _longPressedSpeedData

    override fun updateLongPressedSpeed(value: Float?) {
        _longPressedSpeedData.updateValue(value)
    }

    private val _clickBackData by lazy {
        MutableLiveData<View>()
    }

    override val clickBackData: LiveData<View>
        get() = _clickBackData

    override fun updateClickBack(value: View?) {
        _clickBackData.updateValue(value)
    }

    private val _fullScreenChangeData by lazy {
        MutableLiveData<Boolean>()
    }
    override val fullScreenChangeData: LiveData<Boolean>
        get() = _fullScreenChangeData

    override fun updateFullScreenChange(value: Boolean?) {
        _fullScreenChangeData.updateValue(value)
    }

    private val _speedData by lazy {
        MutableLiveData<List<Pair<Float, String>>>()
    }

    override val speedData: LiveData<List<Pair<Float, String>>>
        get() = _speedData

    override fun updateSpeed(value: List<Pair<Float, String>>?) {
        _speedData.updateValue(value)
    }
}